import com.mysql.cj.jdbc.MysqlDataSource;

import javax.sql.DataSource;
import javax.xml.crypto.Data;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Test {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource) dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/java110?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource) dataSource).setUser("root");
        ((MysqlDataSource) dataSource).setPassword("abc123");

        Connection connection = dataSource.getConnection();

        String sql = "insert into student1 values(1,'张三')";

        PreparedStatement statement = connection.prepareStatement(sql);

        int n = statement.executeUpdate();
        System.out.println(n);

        statement.close();;
        connection.close();
    }
}